<template>
  <div>
    <el-table
      ref="tipsTable"
      :data="tableData"
      border
      highlight-current-row
      @current-change="handleCurrentChange"
      height="450px"
      style="width: 100%; margin-bottom: 10px"
    >
      <el-table-column
        v-for="item in thead"
        :key="item.col_name"
        :prop="item.col_name"
        :label="item.show_name"
        :width="item.list_width"
        align="center"
      ></el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <el-pagination
      v-if="page.pageCount != 1"
      background
      layout="prev, pager, next"
      @current-change="changePage"
      :page-count="page.pageCount"
      style="text-align: right"
    >
    </el-pagination>
  </div>
</template>

<script>

export default {
  props: ["tableid", "module", "order", "notsearch"],
  data() {
    return {
      thead: [], //表头
      tableData: [], //数据
      searchInputDtos: [], //获取查询的数据
      page: {
        pageNumber: 1,
        pageSize: 20,
        pageCount: 1,
      },
      chooseRow: {},
    };
  },
  created() {
    if (!this.notSearch) {
      this.getData();
    }
  },
  methods: {
    //自定义查询
    f_search(dto) {
      this.page.pageNumber = 1;
      this.searchInputDtos = dto;
      this.getData();
    },
    async getData() {
      var parms = {
        orderBy: this.order,
        tableId: this.tableId,
        pageNumber: this.page.pageNumber,
        pageSize: this.page.pageSize,
        listmodule: this.module,
        searchInputDtos: this.searchInputDtos,
      };
      let res = await api.postBody(
        "/admin/api/system/SystemCommonBusinessController/listCommon",
        parms
      );
      this.thead = res.data.listColumn;
      this.tableData = res.data.rows;
      this.page.pageCount = parseInt(res.data.pageCount);
    },
    //分页改变
    changePage(page) {
      this.page.pageNumber = page;
      this.getData();
    },
    // 监听单选事件
    handleCurrentChange(row){
        this.chooseRow = row;
    }
  },
};
</script>

<style>
</style>
